<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pub/taglibs.inc"%>
<title>模块管理</title>
</head>
<body>
	<div id="submitToCloud">
		<input id="errorVersion" type="hidden" name="errorVersion"
			class="text-input" />
		<form id="submitToCloudForm" name="submitToCloudForm" method="post">
			<input type="hidden" id="cloud_resourceId" name="cloud_resourceId" value="${param.resourceId}"/>
			<table cellpadding="0" cellspacing="0" class="l-table-edit"
				style="background: #fff;">
				<tr height="40">
					<td align="right" width="100px"><font color="red">*</font>版本编码：</td>
					<td align="left">
						<select name="cloud_version" id="cloudVersionSelect" class="field"
						onchange="changeCloudVersion()" style="width: 283px; height: 30px"
						class="l-text-field">
						</select>
					</td>
				</tr>
				<tr id="cloud_version_tr" height="40" style="display: none">
					<td align="right" width="100px"><font color="red">*</font>版本编码：</td>
					<td align="left">
						<input id="cloud_versionCode" name="cloud_versionCode" type="text" 
						validate="{required:true}" class="field" style="width: 80px; height: 25px" /> 
						<input id="cloud_version1" name="cloud_version1" value="0" type="text"
						validate="{required:true,digits:true,min: 0, max: 999}"
						class="field" style="width: 60px; height: 25px" /> 
						<input id="cloud_version2" name="cloud_version2" value="0" type="text"
						validate="{required:true,digits:true,min: 0, max: 999}"
						class="field" style="width: 60px; height: 25px" /> 
						<input id="cloud_version3" name="cloud_version3" value="1" type="text"
						validate="{required:true,digits:true,min: 0, max: 999}"
						class="field" style="width: 60px; height: 25px" />
					</td>
				</tr>
				<tr height="80">
					<td align="right"><font color="red">*</font>备注：</td>
					<td align="left" colspan="4">
						<textarea cols="100" rows="4"
							name="cloud_remark" id="cloud_remark" style="width: 283px"
							validate="{required:true,maxlength:200}"></textarea>
					</td>
				</tr>
				<tr height="40">
					<!--  <td align="right" width="100px">Tips：</td>  -->
					<td align="right" width="100px"></td>
					<td align="left">
						<div style="width: 90%; text-align: left; color: red;"
							id="errorVersionMsgFont" color="red"></div>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<script type="text/javascript">
		$(function() {
			loadCloudVersionData();
		})
		//这个是提交云下拉框改变方法
		function changeCloudVersion() {
			var selectStr = $("#cloudVersionSelect option:selected").val();
			if ("addNewVersion" == selectStr) {
				$("#cloud_version_tr").show();
			} else {
				$("#cloud_version_tr").hide();
			}
			var errorVersion = $("#errorVersion").val();
			var versionCode = $("#cloudVersionSelect option:selected").text();
			if (null != errorVersion && errorVersion != ""
					&& errorVersion == versionCode) {
				$("#errorVersionMsgFont").show();
			} else {
				$("#errorVersionMsgFont").hide();
			}
		}
		//这个是加载云的版本数据方法
		function loadCloudVersionData() {
			var flag = false;
			var resourceId = '${param.resourceId}';
			if (null == resourceId || resourceId == "") {
				win.$.ligerDialog.warn('请先保存数据');
				return flag;
			}

			var selectEle = $("#cloudVersionSelect");
			selectEle.html("");
			$
					.ajax({
						url : uploadUrl + 'upload/getVersionData.do',
						type : 'post',
						data : {
							resourceId : resourceId,type:'${param.type}'
						},
						dataType : 'json',
						async : false,
						success : function(data) {
							if (data && data.hasOk) {
								//加载select框数据
								if (null != data.message && data.message != "") {
									var dataJson = JSON.parse(data.message);
									for (var i = 0; i < dataJson.length; i++) {
										if (1 == dataJson[i].isSelect) {
											selectEle
													.append("<option value='"+dataJson[i].id+"' selected>"
															+ dataJson[i].text
															+ "</option>");
											if (0 == dataJson[i].isSameVersion) {//如果不同版本
												//提示不同相同版本
												$("#errorVersion").val(
														dataJson[i].text);
												$("#errorVersionMsgFont")
														.text(
																"版本不一致，本地版本："
																		+ dataJson[i].oldVersion
																		+ "，云版本："
																		+ dataJson[i].id);
												$("#errorVersionMsgFont")
														.show();
											}
										} else {
											selectEle
													.append("<option value='"+dataJson[i].id+"'>"
															+ dataJson[i].text
															+ "</option>");
										}
									}
								}
								flag = true;
							} else {
								win.$.ligerDialog.error(data.message);
								flag = false;
							}
						}
					});

			selectEle.append("<option value='addNewVersion'>新增</option>");
			var selectStr = $("#cloudVersionSelect option:selected").val();
			if ("addNewVersion" == selectStr) {
				$("#cloud_version_tr").show();
			} else {
				$("#cloud_version_tr").hide();
			}
			return flag;
		}
	</script>
</body>
</html>